<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var demoarr=[1,5,44,3,2,1,5,6,3,211,232,12];
    var quickSort = function(arr) {
        console.log(arr)
        if (arr.length <= 1) { return arr; }
        var pivotIndex = Math.floor(arr.length / 2);   //基准位置（理论上可任意选取）
        var pivot = arr.splice(pivotIndex, 1)[0];  //基准数
        var left = [];
        var right = [];
        for (var i = 0; i < arr.length; i++){
            if (arr[i] < pivot) {
                left.push(arr[i]);
            } else {
                right.push(arr[i]);
            }
        }
        return quickSort(left).concat([pivot], quickSort(right));  //链接左数组、基准数构成的数组、右数组
    };
    var res=quickSort(demoarr);
    console.log(res)
</script>
</body>
</html>